﻿<?php
/*
 cookie对回话的影响 未测试,cookie不可以用 可以用发送get url 的方式 传递参数
*/
  session_start();
 //整形字段插入空值 $id='NULL',再插入$id
  require_once("../include/db_mysql.php");
  require_once("../include/updateLogoFile.php");
  $partyId = $_SESSION['partyId'];
  $partyName =$_SESSION['partyName'];  
  
  $link = new SqlClass();
  $link->connect();
  
  $pageUrl = "PartyInfo/$partyName/abc.html";
  $partyIntroduction=$_POST['partyIntroduction'];
  $productIntroduction= $_POST['productIntroduction'];  
  $refreshDateTime = date("Y-m-d H:i:s");
  $message = $_POST['message'];
  $promotionRemark= $_POST['promotionRemark'];	
  $partyAlbumId = $partyId;
  $sqlCommand = "insert into partyPageInfo(pageUrl,partyIntroduction,productIntroduction,refreshDateTime,message,promotionRemark,partyAlbumId)values ('$pageUrl','$partyIntroduction','$productIntroduction','$refreshDateTime','$message','$promotionRemark',$partyAlbumId)";
  $result = $link->exec_sql($sqlCommand);
  
  
 // 生成商家主页
  $sqlCommand = "select partyLogo,fixedPhone from party where partyId = '$partyId'";
  $result = $link->exec_sql($sqlCommand);
  while($row=mysql_fetch_array($result))
    {
		$partyLogo = $row['partyLogo'];
		$fixedPhone = $row['fixedPhone'];
		break;
    }
    $templatePath = 'Template/template.html';
	$fileContent = file_get_contents($templatePath);
	$fileContent = str_replace('{$partyName}',$partyName,$fileContent);
	$fileContent = str_replace('{$partyLogo}',$partyLogo,$fileContent);	
	//str_replace('{$partyLocation}',,$fileContent);
	//str_replace('{$businessCircle}',,$fileContent);
	//str_replace('{$isRegisterBusiness}',,$fileContent);
	$fileContent = str_replace('{$fixedPhone}',$fixedPhone,$fileContent);
	//str_replace('{$landMark}',,$fileContent);
	$fileContent = str_replace('{$message}',$message,$fileContent);
	$fileContent = str_replace('{$refreshDate}',$refreshDateTime,$fileContent);
	$gbkPageUrl = iconv('utf-8' , 'gbk' , $pageUrl);
	$file = fopen($gbkPageUrl,'w+');
	fwrite($file,$fileContent);
	fclose($file);
  
  
  
  $link->close();

?>